package com.linkoog.devtools.http.request.http_send;

import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.StartupUiUtil;
import com.linkoog.devtools.http.HttpPluginIcons;

import javax.swing.*;
import javax.swing.border.CompoundBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class HttpSendLabel extends JBLabel {

    public HttpSendLabel() {
        setIcon(HttpPluginIcons.SEND_ICON);
        this.setIconTextGap(JBUIScale.scale(1));
        this.setHorizontalTextPosition(10);
        this.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBColor.LIGHT_GRAY, 0, 1, 0, 0), JBUI.Borders.empty(0, 10, 0, 4)));
        this.setFont(StartupUiUtil.getLabelFont().deriveFont(1));
        this.setForeground(JBColor.GREEN);
        //this.setHoverBackground(Color.red);
        this.putClientProperty("Button.hoverBackground", JBUI.CurrentTheme.ActionButton.hoverSeparatorColor());


        addMouseListener(new MouseAdapter() {

            Color oldBackground = HttpSendLabel.this.getBackground();

            @Override
            public void mouseEntered(MouseEvent e) {
                setBackground(JBUI.CurrentTheme.ActionButton.hoverBackground());
            }

            @Override
            public void mouseExited(MouseEvent e) {
                setBackground(oldBackground);
            }
        });
    }

}
